package com.diankangwo.factory.service.impl;

import com.diankangwo.factory.dao.TdCommodityMapper;
import com.diankangwo.factory.entity.TdCommodity;
import com.diankangwo.factory.service.CommodityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;

/** 商品接口实现类
 * Created by wuye on 2017/9/7.
 */
@Service("CommodityService")
public class CommodityServiceImpl implements CommodityService{

    @Autowired
    private TdCommodityMapper mapper;

    /**
     * 根据用户名查询
     * @param commodityName
     * @return
     */
    @Override
    public List<TdCommodity> queryByName(String commodityName) {
        return null;
    }

    /**
     * 根据销售渠道查询
     * @param saleshannels
     * @return
     */
    @Override
    public List<TdCommodity> queryBySaleshannels(String saleshannels) {
        return null;
    }


    @Override
    public List<TdCommodity> queryList(Map<String, Object> map) {
        return mapper.queryList(map);
    }

    /**
     * 根据ID查询
     * @param id
     * @return
     */
    @Override
    public TdCommodity queryById(int id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return mapper.queryTotal(map);
    }

    @Override
    @Transactional
    public void save(TdCommodity commodity) {
        mapper.save(commodity);
    }

    @Override
    @Transactional
    public int save2(TdCommodity commodity) {
        return mapper.save2(commodity);
    }

    @Override
    @Transactional
    public void update(TdCommodity commodity) {
        mapper.update(commodity);
    }



    @Override
    @Transactional
    public void delete(int id) {
        mapper.deleteByPrimaryKey(id);
    }

    @Override
    @Transactional
    public void deleteBatch(int[] commodityIds) {
        mapper.deleteBatch(commodityIds);
    }

    /**
     * 根据厂家ID获取商品信息
     * @param factoryid
     * @return
     */
    @Override
    public List<TdCommodity> queryByFactoryId(int factoryid) {
        return mapper.queryByFactoryId(factoryid);
    }


    /**
     * 根据厂家ID获取商品信息
     * @param factoryId
     * @return
     */
    @Override
    public int querybyTotalByFactoryId(int factoryId) {
        return mapper.querybyTotalByFactoryId(factoryId);
    }
}
